<?php require_once('inc/conn.php'); ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
     <link rel="stylesheet" href="layui/css/layui.css">
    <script src="layui/layui.js"  charset="utf-8"></script>
</head>
<body>
     <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>新闻信息列表</legend>
</fieldset>
     <form action="" class="layui-form">
         <table class="layui-table" lay-even="" lay-skin="row">
            <colgroup>
                <col width="50">
                <col width="100">
                <col width="250">
                <col width="50">
                <col width="80">
                <col width="40">
            </colgroup>
             <thead>
             <tr>
                 <td>作者姓名</td><td>新闻标题</td><td>新闻内容</td><td>手机号</td><td>固定电话</td><td>操作</td>
             </tr>
             </thead>
             <?php 
                $total_num=mysql_num_rows(mysql_query("SELECT id FROM biao"));
                $pagesize=5;
                $page_num=ceil($total_num/$pagesize);
                $page=@$_GET['page'];
                if($page<1||$page==''){
                    $page=1;
                }
                if($page>$page_num){
                    $page=$page_num;
                }
                $offset=$pagesize*($page-1);
                $prepage=($page<>1)?$page-1:$page;
                $nextpage=($page<>$page_num)?$page+1:$page;
                $sql="SELECT * FROM biao LIMIT $offset,$pagesize";
                $result=mysql_query($sql);
                while($row=mysql_fetch_array($result)){
              ?>
              <tbody>
              <tr>
                  <td><?=$row['insert_name']?></td><td><?=$row['insert_title']?></td><td><?=$row['insert_content']?></td><td><?=$row['insert_phone1']?></td><td><?=$row['insert_phone2']?></td><td><a href="xinwenxiugai.php?id=<?=$row['id']?>" class="layui-btn layui-btn-primary layui-btn-small">
    <i class="layui-icon">&#xe642;</i>
  </a>
  <a href="xinwendelete.php?id=<?=$row['id']?>" class="layui-btn layui-btn-primary layui-btn-small">
    <i class="layui-icon">&#xe640;</i>
  </a></td>
              </tr>
              </tbody>
              <?php
              }
              ?>
            <tr>
                <td height="43" colspan="7" align="center">
                    <?=$page?>/<?=$page_num?>&nbsp;&nbsp;
                    <a href="?page=1">首页</a>&nbsp;&nbsp;    
                    <a href="?page=<?=$prepage?>">上一页</a>&nbsp;&nbsp;
                    <a href="?page=<?=$nextpage?>">下一页</a>&nbsp;&nbsp;
                    <a href="?page=<?=$page_num?>">尾页</a>
                </td>
            </tr>
             
         </table>
     </form>
</body>
</html>